#include<bits/stdc++.h>
using namespace std;
#include<algorithm>

int main(){
    int n;
    cin>>n;
    vector<int> arr(n);
    for(int i = 0;i < n;i++){
        cin>>arr[i];
    }
    sort(arr.begin(),arr.end());

    //arr[n-1] - arr[0]
    cout<<arr[n-1] - arr[0]<<endl;


    return 0;
}